using System.IO;

namespace ZerAx.TBON
{
    public class TbonFloat : TbonObject
    {
        static TbonFloat()
        {
            factories.Add(TbonType.Float, (s) => new TbonFloat(s));
        }

        public float val;
        public TbonFloat(string name) : base(name)
        {
        }

        public TbonFloat(string name, float val) : base(name)
        {
            this.val = val;
        }

        public override TbonType Type => TbonType.Float;

        public override string GetValueString() => val.ToString();

        public override void ReadValue(BinaryReader reader)
        {
            val = reader.ReadSingle();
        }

        public override void WriteValue(BinaryWriter writer)
        {
            writer.Write(val);
        }
    }
}